package com.jiepos.mpos.biz.channel.controller;


import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.view.RedirectView;

import com.jiepos.mpos.biz.channel.service.ChnServiceCostService;
import com.jiepos.mpos.common.entity.App_Inf_Chn_Service_CostEntity;
import com.jiepos.mpos.core.controller.BaseController;
import com.jiepos.mpos.core.entity.Pagination;

/**
 *
 *
 * <p>标题: ——</p>
 * <p>模块: 通用平台</p>
 * <p>版权: Copyright (c) 2017 江苏杰博实信息技术有限公司
 * @ProjectName:  [mpos]
 * @Package com.jiepos.mpos.biz.channel.controller;
 * @author 余翼膑
 * @version 1.0
 * @since 2018年1月25号
 * @history（历次修订内容、修订人、修订时间等）
 */
@Controller
@RequestMapping("chnServiceCost")
public class ChnServiceCostController extends BaseController {

    @Autowired
    private ChnServiceCostService ChnServiceCostService;



    /**
     * 进入列表页面
     * @param request
     * @param response
     * @param pagination
     * @return
     */
    @RequestMapping("/getChnServiceCostList.do")
    public ModelAndView getChnServiceCostList(HttpServletRequest request, HttpServletResponse response, Pagination pagination){

        ModelAndView model = new ModelAndView("/module/channel/chnservicecost/chnservicecost_list");
        return super.getDetail(request, response, model);
    }
    /**
     * 查询列表信息json数据
     * @param pagination
     * @param appInfChnServeiceCostEntity
     * @return
     */
    @RequestMapping("/ChnServiceCostListJson.do")
    public @ResponseBody
    Map getChnServiceCostListJsonListJson(HttpServletRequest request, Pagination pagination, App_Inf_Chn_Service_CostEntity appInfChnServeiceCostEntity){
        return ChnServiceCostService.getChnServiceCostList(request,pagination, appInfChnServeiceCostEntity);
    }

    /**
     * 进入详细页面
     * @param request
     * @param response
     * @param pagination
     * @param chn_service_cost_uuid
     * @return
     */
    @RequestMapping("/getChnServiceCostDetail.do")
    public ModelAndView getChnServiceCostDetail(HttpServletRequest request, HttpServletResponse response,
                                      Pagination pagination,String chn_service_cost_uuid) {
        ModelAndView model = new ModelAndView("/module/channel/chnservicecost/chnservicecost_detail");
        // 菜单编码
        Map appInfChnServeiceCostEntity = ChnServiceCostService.getChnServiceCostById(chn_service_cost_uuid);
        model.addObject("appInfChnServeiceCostEntity", appInfChnServeiceCostEntity);
        return super.getDetail(request, response, model);
    }

    /**
     * 保存
     * @param request
     * @param response
     * @param appInfChnServeiceCostEntity
     * @return
     */
    @RequestMapping("/saveChnServiceCostDetail.do")
    public ModelAndView saveChnServiceCostDetail(HttpServletRequest request, HttpServletResponse response, App_Inf_Chn_Service_CostEntity appInfChnServeiceCostEntity, String channelno) {

        System.out.println(channelno);
        ChnServiceCostService.saveChnServiceCost(appInfChnServeiceCostEntity,channelno, super.getLoginUser(request, response));
        Map map=super.getLoginUser(request, response);
        return new ModelAndView(new RedirectView("getChnServiceCostList.do"), map);
    }

    /**
     * 获取业务参数
     * @param service_uuid
     * @return
     */
    @RequestMapping("/getServiceUuid.do")
    public @ResponseBody
    String getServiceUuid(String service_param_uuid,String channelno,String chn_service_cost_uuid ){
        String serviceUuid =  ChnServiceCostService.getServiceUuid(service_param_uuid,channelno,chn_service_cost_uuid);
        return serviceUuid;
    }


}
